﻿using CommonPatterns.MVVM;
using OCDP.Client.Services.Clock;
using System;

namespace OCDP.Client.Screens.ClockScreen
{
    public class ClockScreenViewModel : ViewModelBase, IClockScreenViewModel
    {
        public ClockScreenViewModel(IClockService clockService)
        {
            Title = "Binded ClockScreenViewModel !!!";
            clockService.RaisedNewDateTime += RefreshDate;
        }


        #region Properties
        private DateTime date;
        public DateTime Date
        {
            get { return date; }
            set
            {
                if (date != value)
                {
                    date = value;
                    RaisePropertyChanged(() => Date);
                }
            }
        }
        #endregion

        #region Methods
        private void RefreshDate(DateTime newDateTime)
        {
            Date = newDateTime;
        }
        #endregion
    }
}
